import numpy as np
def normalize(data):
    data = np.array(data,float)
    mean_lst = []
    std_lst = []
    for i in range(data.shape[1]):
        x = data[:,i:i+1]
        features_mean = np.mean(x)
        features_std = np.std(x)
        mean_lst.append(features_mean)
        std_lst.append(features_std)
        if features_std != 0:
            x = (x - np.ones([data.shape[0],1],dtype=float)*features_mean)/features_std
        data[:,i:i+1] = x
    #print("mean_values:",mean_lst)
    #print("std_values:",std_lst)
    return data,mean_lst,std_lst

def prepare_for_training(data):
    data_processed = np.copy(data)
    features_mean = 0
    features_deviation = 0
    data_normalized = data_processed
    
    (data_normalized,
        features_mean,
        features_std) = normalize(data_processed)
    data_processed = data_normalized

    data_processed = np.hstack((np.ones([data.shape[0],1]),data_processed))
    return data_processed,features_mean,features_std